import torch.nn as nn
import torch

def get_objectness_loss(objectness_pred,objectness_label):
    # objectness_label = torch.unsqueeze(objectness_label,dim=1)
    objectness_pred = objectness_pred#.transpose(0,1).contiguous()
    objectness_label = objectness_label#.transpose(0, 1).contiguous()
    objectness_label = objectness_label.float()
    # print(objectness_pred.size(),objectness_label.size())

    loss_func = nn.BCEWithLogitsLoss(reduction="mean")
    output_loss = loss_func(objectness_pred, objectness_label)

    return output_loss